package top.misspro.valheimadminsocket.util;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * @author liulinbo
 */
public class MapHelper {

    private Map<String, Object> data;

    private MapHelper() {
        this.data = new LinkedHashMap<>();
    }

    public static MapHelper newInstance() {
        return new MapHelper();
    }

    public MapHelper put(String name, Object Object) {
        this.data.put(name, Object);
        return this;
    }

    public String json() throws JsonProcessingException {
        ObjectMapper mapper = new ObjectMapper();
        return mapper.writeValueAsString(data);
    }

    public Map<String, Object> map() {
        return data;
    }

}
